package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author ：MJS
 * @date ：Created in 2021/5/13  19:26
 * @description：TODO
 * 商品详情页面
 */
@Controller
@Api(description = "api商品详情页面")
public class ItemController {
    @Autowired
    private ItemFeignClient itemFeignClient;
    //https://item.jd.com  /100020909324.html
    @GetMapping("/{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model){
        Map<String,Object>item =itemFeignClient.getItem(skuId);
        model.addAllAttributes(item);
        return "item/index";
    }
}